#ifndef __comm_h
#define __comm_h
#include "main.h"
#define  UART_ENABLE_RE(USARTx)       USARTx->Instance->CR1|= (uint32_t)0x0004            
#define  UART_DISABLE_RE(USARTx)      USARTx->Instance->CR1&= (~(uint32_t)0x0004)  
#define GPRS_MAX_R 1024

typedef enum {offline,online,dail,check,ccid,regist,copyccid,send,deal_receive} GPRS_STATE;
typedef struct{
uint16_t dail_delay;
uint16_t check_delay;
uint16_t shut_delay;
uint16_t ccid_delay;
uint16_t copyccid_delay;
uint16_t regist_delay;
uint16_t send_delay;
uint16_t offline_delay;
uint16_t online_delay;
}_GPRS_DELAY;

typedef struct{
	uint8_t *send_buf;//
	uint8_t *receive_buf;//
	uint16_t data_length;
	uint8_t send_flag;
	uint8_t receive_flag;
	uint16_t regist_interval;
  uint8_t *p_save;	
	GPRS_STATE gprs_state;
	void (*fun_send_data)(uint8_t*,uint16_t);
  uint8_t (*fun_gprs_delay_ms)(uint16_t);
	void (*fun_send_data_length)(uint16_t);
	void (*fun_send_data_package)(uint8_t*,uint16_t);
	_GPRS_DELAY *gprs_delay;
}GPRS_STR;

extern uint8_t GPRS1_RBUF[1024];
extern uint8_t GPRS1_TBUF[1024];
extern GPRS_STR MYGPRS;



void USART_IDLE_IT_HANDLE(UART_HandleTypeDef *huart);
//void GPRS_DATA_HANDLE(GPRS_COM_STR*p);

void GPRS_INI(void);
void GPRS_STATE_MACHINE(GPRS_STR *p);
void GPRS_DEAL_DATA(GPRS_STR *p);
void myiqr(void);
#endif

